#/*
# * Copyright {c} 2020-2021, SERI Development Team
# *
# * SPDX-License-Identifier: Apache-2.0
# *
# * Change Logs:
# * Date         Author          Notes
# * 2023-06-24   Lyons           first version
# */

ifeq ($(shell uname), Linux)
TARGET = ./xemu
PARAM  = -std=c99
LIB    = -lcurses -lpthread
else
TARGET = xemu.exe
PARAM  = 
LIB    = 
endif

BINFILE = ./riscv.bin

.PHONY: build
build:
	@gcc ${PARAM} -DENABLE_TIMER -DENABLE_UART ${LIB} xemu.c -o ${TARGET}

.PHONY: run
run:
	@if [ -e ${BINFILE} ]; then echo; ${TARGET} ${BINFILE}; else echo "${BINFILE} missing!"; fi

.PHONY: clean
clean:
	rm -rf ${TARGET} *.log
	rm -rf *.bin